<!DOCTYPE html>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ include file="/common/common.jsp"%>
<%--<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>--%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

	<head>
		<meta charset="utf-8" />
		<title>厅干部平时考核管理系统</title>
		<%--<link rel="stylesheet" type="text/css" href="<c:url value='/resource/jxkh/css/main.css'/>" />
		<link rel="stylesheet"  href="<c:url value='/resource/jxkh/css/zTreeStyle/zTreeStyle.css'/>" type="text/css" />
		<script type="text/javascript" src="<c:url value='/resource/jxkh/js/jquery-1.11.0.js'/>"></script>
		<script type="text/javascript" src="<c:url value='/resource/jxkh/js/layer/layer.js'/>" ></script>
		<script type="text/javascript" src="<c:url value='/resource/jxkh/js/jquery.ztree.core.js'/>"></script>
		<script type="text/javascript" src="<c:url value='/resource/jxkh/js/jquery.ztree.excheck.js'/>"></script>
		<script type="text/javascript" src="<c:url value='/resource/jxkh/js/jquery.ztree.exedit.js'/>"></script>--%>
		<!--树结构-->
		<style type="text/css">
			#jedatebox{z-index: 9999999999999999999999999999!important;}
		</style>
<script type="text/javascript">
	$(function(){
		initTable();//初始化表格
		$.fn.zTree.init($("#treeDemo"), setting);
	});
	var setting = {
		async : {
			enable : true,
			url : "/jxkh/dept/dragtree.json",
			dataType : "json",
			type : 'get',
			autoParam : [ "deptId" ],
			dataFilter : function(treeId, parentNode, childNodes) {
				$.each(childNodes,function(i,node){
					node.drag = true;
				});
				return childNodes.data
			}
		},
		callback : {
			onClick : zTreeOnClick
		},
		data : {
			key:{
				name:"alias"
			},
			simpleData : {
				enable : true,
				idKey : "deptId",
				pIdKey : "parentId",
				rootPId : 0
			}
		},
		edit:{
			enable:true,
			showRemoveBtn:false,
			showRenameBtn:false
		}
	};
	function zTreeOnClick(event, treeId, treeNode) {
		var opt = {
			url :"/jxkh/department/findDepartmentInfoByDeptId.json",//部门人员列表
			silent: true,
			query:{
				deptId:treeNode.deptId
			}
		};
		$("#boot_table").bootstrapTable('refresh', opt);
	}
</script>
	</head>

	<body>
	<div class="njga">
		<div class="bmkhcp"  style="background: #fff;overflow: hidden;">
				<div class="bmkhcp_lf" style="width: 100%;">
					<div class="title">部门管理</div>
					<div class="rygl">
						<div class="rygl_lf" id="rygl_lf">
							<ul id="treeDemo" class="ztree" style="width:220px;overflow-x:hidden;height:440px"></ul>
						</div>
						<div class="rygl_rt" id="rygl_rt">
							<div class="rygl_rt_main">
								<!--新增rt头部（人员调度）-->
								<%--<div class="rygl_rt_top">
									<div class="rydd"  id="rygl_bmtz">
										<img src="<c:url value='/resource/jxkh/images/rydd_icon.png'/>" />新增部门
									</div>
									<div class="ul_bj">
										<div class="ul_bj_lf" id="bmbj">编辑</div>
										<div class="ul_bj_lf ul_bj_rt">删除</div>
									</div>
									<button type="button" class="but">保存</button>
									<div class="inpt">
										<input type="text" placeholder="搜索部门" class="inpt_lf" />
										<div class="inpt_rt">
											<img src="<c:url value='/resource/jxkh/images/search.png'/>" />
										</div>
									</div>
								</div>--%>
								<table id="boot_table"></table>
								<!--新增rt头部（人员调度）结束-->
								<%--<table class="table_rygl">
									<tr>
										<th width="7%">
											<input type="checkbox" id="chkAll" style="margin-left: 2px;" />
										</th>
										<th width="21%">单位名称</th>
										<th width="21%">单位简称</th>
										<th width="21%">单位编码</th>
										<th width="21%">上级单位</th>
									</tr>
									<c:forEach var="i" items="${list}" begin="10" end="15" varStatus="index">
									<tr>
										<td>
											<input type="checkbox" name="chkGuid" value="${i.dbid}" />
										</td>
										<td>${i.deptNum}</td>
										<td>${i.deptShortName}</td>
										<td>${i.deptName}</td>
										<td>${i.superiorDeptName}</td>
									</tr>
									</c:forEach>
								</table>
								<!--分页-->
								<div class="paging">
									<a href="#">首页</a>
									<a href="#" class="a_hov">1</a>
									<a href="#">2</a>
									<a href="#">3</a>
									<a href="#">4</a>
									<a href="#">5</a>
									<a href="#">6</a>
									<a href="#">末页</a>
								</div>--%>
							</div>
						</div>
					</div>

				</div>

		</div>
	</div>
	<!--新增周报弹出框-->
	<div class="date_pop date_pop1" id="date_pop">
		<div class="row_pop_row">
			<div class="row_pop_row_lf">
				<div class="row_pop_row_lf_top">
					<input type="text" placeholder="请输入查询关键字" class="inpt" />
				</div>
				<div class="row_pop_row_lf_b">
					<ul id="tree" class="filetree">
						<li><span class="folder">厅长办公室</span>
							<ul>
								<li><span class="folder">指挥中心</span>
									<ul>
										<li><span class="folder">情报室</span>
											<ul>
												<li><span class="folder">科室1</span>
													<span class="folder">科室2</span>
													<span class="folder">科室3</span>
													<span class="folder">科室4</span>

												</li>
											</ul>
										</li>
										<li><span class="folder">指挥调度室</span></li>
										<li><span class="folder">指挥调度室</span></li>
										<li><span class="folder">指挥调度室</span></li>
									</ul>
								</li>

							</ul>
						</li>
						<li><span class="folder">办公室</span>
							<ul>
								<li><span class="folder">部门管理</span></li>
								<li><span class="folder">部门管理</span></li>
							</ul>
						</li>
					</ul>
				</div>
			</div>
			<div class="row_pop_row_rt">
				<p>已选部门：<span>3</span>/<span>100</span></p>
				<div class="name_wraper">
					<div class="name">情报室
						<div class="del">
							<img src="<c:url value='/resource/jxkh/images/guanbi.png'/>" />
						</div>
					</div>
					<div class="name">指挥调度室
						<div class="del">
							<img src="<c:url value='/resource/jxkh/images/guanbi.png'/>" />
						</div>
					</div>
					<div class="name name_hov">情报室
						<div class="del">
							<img src="<c:url value='/resource/jxkh/images/guanbi.png'/>" />
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>
	<!--弹出框-->
	<script type="text/javascript">
		function getContentSize() {
			var h = document.documentElement.clientHeight; //clientHeight内容可视区域的高度
			ch = (h - 121) + "px";
			document.getElementById("rygl_lf").style.height = ch;
			document.getElementById("rygl_rt").style.height = ch;
		}
		window.onload = getContentSize; //页面加载时调用getContentSize()
		window.onresize = getContentSize; //当改变窗口大小时会出发getContentSize()
		$(document).ready(function() {
			$("#date_pop").hide();
			//部门调整弹出框
			$("#rygl_bmtz").on("click", function() {
				var open = layer.open({
					type: 1, //0（信息框，默认）1（页面层）2（iframe层）3（加载层）4（tips层）。
					shift: 1, //动画    0-6     css3动画
					closeBtn: 1, //关闭按钮  0 不显示  style  1和2  标题为 false 2
					btn: ['确定', '取消'],
					title: ['新增部门', 'background:#5f9ad1;color:#fff;text-align: left;font-size: 18px;'],
					area: ['508px', '520px'], //宽高
					content: $("#date_pop") //iframe层-禁滚动条  $("#photosDemo").html()   'http://www.baidu.com/'
				});
			});
			//部门调整弹出框结束

			//全选与取消
			$("#chkAll").click(function() {
				$("[name=chkGuid]:checkbox").prop("checked", this.checked);
			});
			//当所有checkbox选中，全选选中
			$("[name=chkGuid]:checkbox").click(function() {
				var flag = true;
				$("[name=chkGuid]:checkbox").each(function() {
					if(!this.checked) {
						flag = false;
					}
				});
				$("#chkAll").prop("checked", flag);
			})

		});
		/*function submitForm(){
			alert(123123);
		}*/
	</script>
	<script>
		$(function(){
			$("#bmbj").click(function(){
				var dbid = $("table input[type=checkbox]:checked:eq(0)").val();
				if(dbid!=undefined){
					var open =  layer.open({
						type: 2,                                    //0（信息框，默认）1（页面层）2（iframe层）3（加载层）4（tips层）。
						shift: 1,//动画    0-6     css3动画
						closeBtn: 1,       //关闭按钮  0 不显示  style  1和2  标题为 false 2
						btn: ['确定', '取消'],
						shade: [0.8, '#393D49'],
						btn1: function(index, layero){
							var newpsw = $(layero).find("iframe")[0].contentWindow;
							newpsw.submitForm();
						},
						title:['部门编辑','background:#5f9ad1;color:#fff;text-align: left;font-size: 18px;'],
						area: ['400px', '200px'], //宽高
						content:"<c:url value='/department/findDepartmentInfo.html?dbid='/>"+dbid//iframe层-禁滚动条  $("#photosDemo").html()   'http://www.baidu.com/'
					});
				}else {
					layer.open({
						title: '信息'
						, content: "没有选中修改对象"
					});
				}
			});
		});
	</script>
	<script>
		var $table = $('#boot_table'),
				$remove = $('#remove'),
				selections = [];
		function initTable() {
			$table.bootstrapTable({
				idField: "id",
				pagination: "true",
				sidePagination: 'server',
				url: "<c:url value='/department/allDepartmentInfo.json'/>",
				height: 620,
				columns: [
					{
						title: '序号',
						field: 'Number',
						align: 'center',
						formatter: function (value, row, index) {
							var page = $table.bootstrapTable("getOptions");
							return ((page.pageNumber- 1 )* page.pageSize)+ index+1;
						}
					}, {
						title: '部门名称',
						field: 'name',
						align: 'center',
						valign: 'middle'
					}, {
						field: 'deptId',
						title: '部门编号',
						align: 'center',
					}, {
						field: 'parentId',
						title: '上级部门编号',
						align: 'center',
					}, {
						field: 'parentName',
						title: '上级部门名称',
						align: 'center',
					},{
						field: 'operate',
						title: '操作',
						align: 'center',
						valign: 'middle',
						formatter: function(value, row, index){
							return [
								'<a href="javascript:bmbj('+row.dbId+')">编辑',
								'</a>  '/*,
								'<a href="javascript:bmsc('+row.dbId+')" >删除',
								'</a>  '*/
							].join('');
						}
					}
				]
			});
		}

		function bmbj(dbid){
			var open =  layer.open({
				type: 2,                                    //0（信息框，默认）1（页面层）2（iframe层）3（加载层）4（tips层）。
				shift: 1,//动画    0-6     css3动画
				closeBtn: 1,       //关闭按钮  0 不显示  style  1和2  标题为 false 2
				btn: ['确定', '取消'],
				shade: [0.8, '#393D49'],
				btn1: function(index, layero){
					var newpsw = $(layero).find("iframe")[0].contentWindow;
					newpsw.submitForm();

				},
				title:['部门编辑','background:#5f9ad1;color:#fff;text-align: left;font-size: 18px;'],
				area: ['500px', '400px'], //宽高
				content:"<c:url value='/department/findDepartmentInfo.html?dbid='/>"+dbid//iframe层-禁滚动条  $("#photosDemo").html()   'http://www.baidu.com/'
			});
		}
		function bmsc(dbid){
			var open = layer.open({
				btn: ['确定', '取消'],
				btn1: function (index, layero) {
					$.ajax({
						type: "GET",
						url: "<c:url value="/department/delDepartmentInfo.json"/>",
						data: {dbid:dbid},
						dataType: "json",
						success: function(rs){
							if (rs.data.status == 1) {
								showMessage("操作成功！");
							} else {
								showMessage(rs.data.body);
							}
						},
						error: function(){
							showMessage("失败！");
						}
					});
				},
				title: '信息'
				,content:'确定删除吗？'
			});
		}

		/*function getHeight() {
			return $(window).height() - $('h1').outerHeight(true);
		}*/
	</script>
	</body>

</html>